package com.example.rabbitmq.demo.listener;

import com.example.rabbitmq.demo.entity.OrderEntity;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;

@Service
@RabbitListener(queues = "order-release-queue")
@Slf4j
public class OrderReleaseListener {

    @RabbitHandler
    public void orderReleaseQueueConsumer(OrderEntity order, Channel channel, Message message) throws IOException {
        log.info(">>>>>>>>>>>>>>>close order :"+order.getMemberUsername());
        try{
            //channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
        }catch (Exception e){
            //channel.basicReject(message.getMessageProperties().getDeliveryTag(),true);
        }
    }
}
